#!/usr/bin/env python3
"""
创建测试用户账号
"""

from app import app
from models.models import User, db

def create_test_user():
    with app.app_context():
        # 检查是否已存在测试用户
        existing_user = User.query.filter_by(username='testuser123').first()
        if existing_user:
            print("测试用户已存在，删除旧账号...")
            db.session.delete(existing_user)
            db.session.commit()
        
        # 创建新的测试用户
        user = User(
            username='testuser123',
            age=25,
            gender='男',
            ethnicity='汉族',
            mandarin_level='二级甲等',
            role='user'
        )
        user.set_password('password123')
        
        db.session.add(user)
        db.session.commit()
        
        print("✅ 测试用户创建成功!")
        print("   用户名: testuser123")
        print("   密码: password123")
        print("   角色: user")

if __name__ == '__main__':
    create_test_user()
